Ext.define("Triends.Model.Noticelist",{
	extend: "Ext.data.Model",
	config: {
		fields: [
			"Number", "Title", "Content", "Date", "Time"
		]
	}
});

var noticestore = Ext.create("Ext.data.Store",{
	model: "Triends.Model.Noticelist",
	id: 'noticestore',
	proxy: {
		type: "jsonp",
		url: 'http://itscreater.cafe24.com/Triends/Notice.jsp', 
		callbackkey: 'callback'
	},
	sorters: [
		{
			property: 'DATE',
			direction: 'DESC'
		},
		{
			property: 'TIME',
			direction: 'DESC'
		}
	]
});

Ext.define('Triends.view.Noticelist', {
	extend: 'Ext.Panel',
	xtype: 'noticelist',
	id: 'noticelist',
	config: {
		items: [{
	   		xtype: 'titlebar',
 			ui: 'light',
 			docked: 'top',
 			style: 'margin-bottom:20px',
 			title: 'Notice'
	   	},
	   	{
	   		xtype: 'list',
	   		scrollable: false,
	   		margin: 10,
	   		pressedCls: "x-item-selected",
			selectedCls: "",
			pressedDelay: 50,
 			style: 'background:white;',
	 		store: noticestore,
		   	itemTpl: "<table width='100%' cellpadding='0'>"+
								"<tr>" +
									"<td valign='center' style='word-break:break-all'><font size='2'><b>{Title}</b></font></td>" +
									"<td width='30' align='right' style='word-break:break-all;padding-top:5px'><img src='resource/images/arrow2.png' width='15px' height='25px'></td>" +
								 "</tr>" +
							"</table>",
		   	listeners: {
		   		itemtap: function(list, index, target, model, e, eOpts) {
			    	var noticetitle = Ext.getCmp('noticetitle');
			    	var noticecontentpanel = Ext.getCmp('noticecontentpanel');
			    	noticetitle.setTitle("<font size='3'>"+model.data.Title+"</font>");
			    	noticecontentpanel.setData(model.data);
			    	
			    	Triends.app.getHistory().add(Ext.create('Ext.app.Action', {
	            		url: 'mainpage/settings/noticeinfo'
		        	}));
	   			}
	   		}
	   	}]
	}
});

